package be.dch.objectprops.impl;

import be.dch.objectprops.ParserFinder;

import com.google.inject.Inject;

public class ObjectReader {

    private transient String inputPrefix;
    @Inject
    private ParserFinder finder;

    public Object readObject(final Class<?> clazz) {
	this.inputPrefix = clazz.getSimpleName();
	final Object result = ObjectUtil.newInstance(clazz);
	if (result != null) {
	    return this.finder.read(new StringBuilder(this.inputPrefix), result);
	}
	return null;
    }

    public Object readObject(final String prefix, final Class<?> clazz) {
	this.inputPrefix = prefix;
	final Object result = ObjectUtil.newInstance(clazz);
	if (result != null) {
	    return this.finder.read(new StringBuilder(this.inputPrefix), result);
	}
	return null;
    }

    
    protected void setFinder(ParserFinder finder) {
	this.finder = finder;
    }
}
